package com.feifan.web.controller.oa;

import com.feifan.common.annotation.Log;
import com.feifan.common.core.controller.BaseController;
import com.feifan.common.core.domain.AjaxResult;
import com.feifan.common.core.page.TableDataInfo;
import com.feifan.common.enums.BusinessType;
import com.feifan.oa.domain.HolidayWorkingDate;
import com.feifan.oa.service.IHolidayWorkingDateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调休时间Controller
 * @author 非凡
 * @date 2020-07-01
 */
@Controller
@RequestMapping("/oa/workingDate")
public class HolidayWorkingDateController extends BaseController {
    private String prefix = "oa/vacation/workingDate";

    @Autowired
    private IHolidayWorkingDateService holidayWorkingDateService;

    @RequiresPermissions("oa:workingDate:view")
    @GetMapping()
    public String workingDate() {
        return prefix + "/workingDate";
    }

    /**
     * 查询调休时间列表
     */
    @RequiresPermissions("oa:workingDate:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HolidayWorkingDate holidayWorkingDate) {
        startPage();
        List<HolidayWorkingDate> list = holidayWorkingDateService.selectHolidayWorkingDateListByHId(holidayWorkingDate);
        return getDataTable(list);
    }

    /**
     * 批量删除调休时间
     */
    @RequiresPermissions("oa:workingDate:remove")
    @Log(title = "调休时间", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String id) {
        return toAjax(holidayWorkingDateService.deleteHolidayWorkingDateById(Long.parseLong(id)));
    }
}
